﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using COFE.Core;
using NUnit.Framework;

namespace COFE.Data
{
    public class DBEntryListManager : IEntryListManager
    {
        #region Constructor

        public DBEntryListManager(DBUserProfile userProfile)
        {
            _userProfile = userProfile;
            _userId = userProfile.UserName;
        }

        #endregion

        #region Methods

        public void RegisterEntryList(IEntryList entryList)
        {
            COFEShared.EntryListRegistrar.RegisterEntryList(entryList);
        }

        public void RemoveEntryList(string name)
        {
            COFEShared.EntryListRegistrar.RemoveEntryList(name);
        }

        public ICustomEntryList CreateCustomEntryList(string name)
        {
            ICustomEntryList customEntryList = new COFE.Core.CustomEntryList(name);
            RegisterEntryList(customEntryList);

            customEntryList = this[name] as ICustomEntryList;
            Assert.IsNotNull(customEntryList);
            return this[name] as ICustomEntryList;
        }

        public IAutoEntryList CreateAutoEntryList(string name, IDirectoryInfo rootDir, string filterString)
        {
            IAutoEntryList autoEntryList = new COFE.Core.AutoEntryList(Guid.NewGuid(), name, rootDir, filterString);
            RegisterEntryList(autoEntryList);

            //autoEntryList = this[name] as IAutoEntryList;
            //Assert.IsNotNull(autoEntryList);
            //return this[name] as IAutoEntryList;
            return autoEntryList;
        }

        public IAutoEntryList CreateAutoEntryList(string name, string filterString)
        {
            IAutoEntryList autoEntryList = new COFE.Core.AutoEntryList(Guid.NewGuid(), name, filterString);
            RegisterEntryList(autoEntryList);

            autoEntryList = this[name] as IAutoEntryList;
            Assert.IsNotNull(autoEntryList);
            return this[name] as IAutoEntryList;
        }

        #endregion

        #region Data

        DBUserProfile _userProfile;
        string _userId;

        #endregion

        #region Public Properties

        string[] IEntryListManager.EntryLists
        {
            get { return COFEShared.EntryListRegistrar.GetEntryLists(); }
        }

       
        public IEntryList this[string name]
        {
            get { return COFEShared.EntryListRegistrar[name]; }
        }

        #endregion





      
    }
}
